//
//  PatrolChooseView.m
//  警用舆情平台
//
//  Created by 魏强 on 15/5/21.
//  Copyright (c) 2015年 魏强. All rights reserved.
//

#import "PatrolChooseView.h"
@interface PatrolChooseView ()
@property (nonatomic, strong) UIButton *selelctBtn;
@property (strong, nonatomic) IBOutlet UIButton *keywordBtn;
@property (weak, nonatomic) IBOutlet UIButton *plateBtn;
@property (weak, nonatomic) IBOutlet UIButton *webBtn;
- (IBAction)patrolBtnClick:(id)sender;
@end
@implementation PatrolChooseView

- (instancetype)init
{
    if (self = [super init]) {
        self = [[[NSBundle mainBundle] loadNibNamed:@"PatrolChooseView" owner:nil options:nil]lastObject];
    }
    self.selelctBtn = self.webBtn;
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
}
- (void)setSelelctBtn:(UIButton *)selelctBtn
{
    if (_selelctBtn) {
        _selelctBtn.selected = NO;
        self.selelctBtn.layer.borderWidth = 0;
    }
    _selelctBtn = selelctBtn;
    selelctBtn.selected = YES;
    selelctBtn.layer.borderWidth = 1;
    selelctBtn.layer.borderColor = KDColor.CGColor;
    selelctBtn.layer.cornerRadius = 5.0;
}

- (IBAction)patrolBtnClick:(id)sender {
    self.selelctBtn = sender;
    if (_delegate &&[_delegate respondsToSelector:@selector(patrolChooseView:patrolBtnClickWithType:)]) {
        patrolBtnType type ;
        if (sender == self.webBtn) {//如果是网站巡查被点击了，就传送这个
            type = patrolBtnTypeWeb;
        }else if (sender == self.plateBtn){//如果是板块巡查被点击了，就传送这个
            type = patrolBtnTypeplate;
        }else{//如果是关键字巡查被点击了，就传送这个
            type = patrolBtnTypeKeyword;
        }
        [_delegate patrolChooseView:self patrolBtnClickWithType:type];
    }
    
}
@end
